<template>
	<view class="addPaitient">
		<view class="main">
			<view class="items">
				<view class="label">姓名</view>
				<view class="val" >
					<u-input @input="inpiutval" type="text" placeholder="请填写" v-model="params.username" :clearable="false"
						style="height:90rpx;width: 100%;margin-top: 20rpx;">
					</u-input>
				</view>
			</view>
			<view class="items">
				<view class="label">{{'身份证号'}}</view>
				<view class="val" >
					<u-input type="text" placeholder="请填写" v-model="params.visitCardNo" :clearable="false"
						style="height:90rpx;width: 100%;margin-top: 20rpx;">
					</u-input>
				</view>
			</view>
			<view class="items">
				<view class="label">性别</view>
				<view class="val" @tap="selectSexHandle"><u-input input-align="left" placeholder-style="linght-linght:100rpx;" placeholder="请选择" type="idcard" v-model="this.sexLabel" :clearable="false" style="height:90rpx"
					@focus="selectSexHandle">
				</u-input>
				<u-icon name="arrow-right"></u-icon></view>
			</view>
			<view class="items">
				<view class="label">出生年月</view>
				<view class="val">
					<u-input placeholder="请选择" input-align="left" v-model="params.birthday" :clearable="false" style="height:90rpx"
						@focus="chooseDate">
					</u-input>
					<u-icon @tap="chooseDate" name="arrow-right"></u-icon>
				</view>
			</view>
			<view class="items">
				<view  class="label">{{'手机号'}}</view>
				<view class="val" >
					<u-input type="number" placeholder="请填写" v-model="params.mobile" :clearable="false"
						style="height:90rpx;width: 100%;margin-top: 20rpx;">
					</u-input>
				</view>
			</view>
			<view class="add-btn-row">
				<u-button type="default" shape="circle" text="添加" class="add-btn" @click="addHandle" hover-class="none">添加
				</u-button>
			</view>
		</view>
		<!-- 性别选择弹出框 -->
		<u-popup v-model="show" @close="close" mode="bottom" class="select-sex">
			<view>
				<view class="sex-row" @tap="chooseHandle('男')">
					<text>男</text>
				</view>
				<view class="sex-row" @tap="chooseHandle('女')">
					<text>女</text>
				</view>
				<view class="cancel" @tap="close">
					<text>取消</text>
				</view>
			</view>
		</u-popup>
		<!-- 时间弹出框 -->
		<view>
			<u-picker v-model="dateShow" :params="date" @confirm="dateConfirm"></u-picker>
		</view>
	</view>
</template>

<script>
	import {API} from '@/config/myApi.js';
	import { lk_buyer,lk_common,lk_expert,lk_seller,lk_manager,lk_consumer } from '@/config/myConfig.js';
	export default {
		data() {
			return {
				sexLabel: '',
				params: {
					birthday: "",
					// createTime: "2022-10-14",
					id: "",
					mobile: "",
					sex: '',
					// userId: 1578209345232531500,
					username: "",
					visitCardNo: "",
					//身份证号
				},
				show: false, // sex选择开关
				dateShow: false, // 年月选择开关
				date: {
					year: true,
					month: true,
					day: true,
				},
			    patient: [
			    	{
			    		label: '姓名',
			    		val: 'username',
			    	},
			    	{
			    		label: '身份证号',
			    		val: 'username',
			    	},
			    	{
			    		label: '性别',
			    		val: 'username',
			    	},
			    	{
			    		label: '出生日期',
			    		val: 'username',
			    	},
					{
						label: '手机号',
						val: 'username',
					}
			    ],
			}
		},
		onLoad() {
			// this.getType();
		},
		methods: {
			async addHandle() {
				console.log("添加咨询人",this.params);
				
				
				// if (this.params.sex==="男") {
				// 	this.params.sex = 0
				// } else{
				// 	this.params.sex = 1
				// }
				let res = await  API.addPatient(this.params)
				if (res.code===200) {
				    console.log("添加咨询人结果",res);
			       	// console.log('添加患者');
			    	uni.navigateBack()
				}
				// uni.navigateTo({
				// 	url:'/pages/mine/myConsultation/startConsulting'
				// })
			},
			
			
			
		// 	switchBack() {
		// 		console.log('dddff')
		// 		uni.switchTab({
		// 			url: '/pages/tabbar/user/my'
		// 		})
		// 	},
		// 	navTo(label,val){
		// 	    let url = '/pages/tabbar/user/personalCenter/perEdit'
		// 	    let param = {
		//             label: label,
		//             val: val
		//         }
		// 	    this.$navTo.navTos(url,param)
		// 	},
		// 	// getUserInfo() {
		// 	// 	// const data = uni.getStorageSync('userDetail')
		// 	// 	API.getMember().then(res=> {
		// 	// 		console.log('ddd',res)
		// 	// 		this.info = res.result;
		// 	// 	})
		// 	// },
		// 	saveEdit(lab,val) {
		// 		let pram= {};
		// 		if(lab=='head') {
		// 			pram = {};
		// 			pram.face = val;
		// 		}
		// 		if(lab=='sex') {
		// 			pram = {}
		// 			pram.sex = val;
		// 		}
		// 		if(lab=='birth') {
		// 			pram = {}
		// 			pram.birthday = val;
		// 		}
		// 		console.log('editOwngggg')
		// 		API.editOwn(pram).then(res=> {
		// 			// console.log('editOwn',res)
		// 			if(res.code==200) {
		// 				this.$u.toast(res.message);
		// 			}
		// 		})
		// 		// address, birthday, face, nickName, region, regionId, sex
		// 	},
			

		// 	//弹出框的关闭
			close() {
				this.show = false;
				this.headShow = false;
			},
			selectSexHandle(e) {
				this.show = true;
				// console.log('ggg',e);
			},
			inpiutval(e) {
				console.log('kkk',e)
				// 输入的值
			},
		// 	//弹出框选择性别
			chooseHandle(sex) {
				this.sexLabel = sex;
				if(sex==="男") {
					this.params.sex = '1';
				}else {
					this.params.sex = '0';
				}
				// this.params.sex.label = sex
				// this.info.sex = this.sex
				console.log('sss',sex)
				// this.saveEdit('sex',this.sex);
				this.show = false;
				
			},
		// 	//呼出日期选择器
			chooseDate() {
				this.dateShow = true;
			},
		// 	//选择日期后自动填入
			dateConfirm(val) {
				this.params.birthday = val.year + '-' + val.month + '-' + val.month;
				// this.saveEdit('birth',this.info.birthday);
				console.log('srsrsr',val,this.info.birthday);
			},
		// 	//监听身高发生改变，进行处理
		// 	heightHandle(val){
		// 		if(val < 0){
		// 			this.params.height = "";
		// 		}else if(val > 300){
		// 			this.params.height = 300;
		// 		}
		// 	},
		// 	//监听身高体重发生改变，进行处理
		// 	weightHandle(val){
		// 		if(val < 0){
		// 			this.params.weight = "";
		// 		}else if(val > 200){
		// 			this.params.weight = 200;
		// 		}
		// 	},
		}
	}
</script>

<style lang="scss" scoped>
	// @import '@/pages/tabbar/aless/personalInformation.scss';


.addPaitient {
	padding: 24rpx 30rpx;
	box-sizing: border-box;
	position: relative;
	.main {
		padding: 0 24rpx;
		box-sizing: border-box;
		background: #FFFFFF;
		border-radius: 14rpx;
		.items {
			display: flex;
			justify-content: start;
			align-items: center;
			height: 110rpx;
			border-top: 1px #E3E3E3 solid;
			font-size: 30rpx;
			&:nth-child(1) {
				border: none;
			}
			.label {
				width: 190rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #333333;
			}
			.val {
				width: 500rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #999999;
				display: flex;
				/deep/.u-iconfont {
					margin-left: 17rpx;
				}
				/deep/.u-input {
					height: 110rpx;
					line-height: 110rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #999999;
					display: flex;
				}
				/deep/.uni-input-input, .uni-input-placeholder {
					height: 100rpx;
					padding-top: 10rpx;
					line-height: 110rpx;
					font-family: PingFang SC;
					font-weight: 500;
					font-size: 30rpx;
					color: #999999 !important;
				}
				.portrait {
					display: flex;
					.img {
						width: 60rpx;
						height: 60rpx;
						border-radius: 50%;
						align-items: center;
					}
				}
			}
		}
		
		
		.add-btn-row {
			width: 690rpx;
			position: fixed;
			left: 30rpx;
			bottom: 32rpx;
			.add-btn {
				background-color: #F4333C;
				color: #fff;
				height: 90rpx;
			}
			
			.u-hairline-border:after {
				border: none;
			}
		}
	}
	//选择性别
	.select-sex,
	.select-head {
		width: 710rpx;
		margin: 0rpx auto 40rpx;
		overflow: hidden;
		/deep/.u-drawer-content {
			border-radius: 10rpx !important;
			overflow: hidden;
		}
		.sex-row,
		.head-row {
			height: 113rpx;
			text-align: center;
			line-height: 113rpx;
			font-size: 30rpx;
			font-weight: bold;
		}
		.cancel {
			height: 100rpx;
			line-height: 100rpx;
			color: #666666;
			font-weight: 100;
			text-align: center;
			border-top: 1rpx solid #E3E3E3;
		}
	}
}







	.add-patient-content {
		padding: 30rpx;
	
		.add-patient-msg {
			padding: 0rpx 24rpx;
			background: #fff;
			border-radius: 12rpx;
	
			.patient-msg-row {
				height: 109rpx;
				border-bottom: 1rpx solid #E3E3E3;
				display: flex;
				align-items: center;
				overflow: hidden;
				>text {
					display: block;
					width: 184rpx;
					font-size: 15px;
					font-weight: bold;
				}
			}
	
			.patient-msg-row:last-child {
				border-bottom: none;
			}
		}
	}
</style>
